package com.example.techstudy.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.techstudy.entity.MtTask;
import com.example.techstudy.mapper.MtTaskMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author: ls
 * @date: 2022/4/9
 * @description:
 */
@Service
public class MtTaskService {

    @Resource
    private MtTaskMapper mapper;


    public void test(){
        LambdaQueryWrapper<MtTask> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(MtTask::getVersion, 3)
                .eq(MtTask::getYn, 1)
                .and(i ->
                        i.eq(MtTask::getStatus, 3)
                                .or(j -> j.eq(MtTask::getStatus, 1)
                                        .between(MtTask::getNextExecTime, new Date(new Date().getTime() - 5*60*1000), new Date()))
                );
        List<MtTask> tasks = mapper.selectList(queryWrapper);
    }
}
